const {ipcMain} = require('electron');
const db = require('../service/db');

function registerSTARIpc() {

    // 获取收藏列表
    ipcMain.handle('star:getList', async (event, {limit, offset}) => {
        return await db.getStarList(limit, offset);
    });

    // 获取收藏总数
    ipcMain.handle('star:getCount', async () => {
        return await db.getStarCount();
    })

    // 删除收藏
    ipcMain.handle('star:removeItem', async (event, {id}) => {
        return await db.removeStarItem(id);
    })

    // 增加收藏
    ipcMain.handle('star:addItem', async (event, {ids, name, answers}) => {
        return await db.addStarItem(ids, name, answers);
    })


}

module.exports = registerSTARIpc;